package com.vt.admin.api.dto.user.structure;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.ListMultimap;
import lombok.Data;

import java.util.List;

/**
 * @Auther: PanZha
 * @Date: 2018/10/30 18:13
 */
@Data
public class UserOrganStructureItem {
    private String id;
    private String name;
    @JsonIgnore
    private int type;
    @JsonIgnore
    private int no;
    @JsonIgnore
    private String userId;

    /**
     * group by userId
     *
     * @return
     */
    public static ListMultimap<String, UserOrganStructureItem> groupByUserId(List<UserOrganStructureItem> all) {
        ListMultimap<String, UserOrganStructureItem> multimap = ArrayListMultimap.create();

        for (UserOrganStructureItem item : all) {
            multimap.put(item.getUserId(), item);
        }
        return multimap;
    }
}
